﻿using Mobile.Controllers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using Mobile.Models;
using System.Web.Mvc;
using System.Web.Security;

namespace Mobile.Tests
{
    
    
    /// <summary>
    ///This is a test class for AccountControllerTest and is intended
    ///to contain all AccountControllerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AccountControllerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for AccountController Constructor
        ///</summary>
        // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
        // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
        // whether you are testing a page, web service, or a WCF service.
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void AccountControllerConstructorTest()
        {
            AccountController target = new AccountController();
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for ChangePassword
        ///</summary>
        // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
        // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
        // whether you are testing a page, web service, or a WCF service.
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void ChangePasswordTest()
        {
            AccountController target = new AccountController(); // Initialize controller
            ChangePasswordModel model = new ChangePasswordModel(); // Initialize new model
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize expected to view type
            ActionResult actual;
            actual = target.ChangePassword(model);

            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for ChangePassword
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void ChangePasswordTestWithoutModel()
        {
            AccountController target = new AccountController(); // Initialize controller
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize expected to view type
            ActionResult actual;
            actual = target.ChangePassword();

            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for ChangePasswordSuccess
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void ChangePasswordSuccessTest()
        {
            AccountController target = new AccountController(); // Initialize controller
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize expected to view type
            ActionResult actual;
            actual = target.ChangePasswordSuccess();

            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for ErrorCodeToString
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        [DeploymentItem("Mobile.dll")]
        public void ErrorCodeToStringTest()
        {
            MembershipCreateStatus createStatus = new MembershipCreateStatus(); // Initialize a generic status
            string expected = string.Empty; // Initializing to an empty string as we currently don't have exact value to test
            string actual;
            actual = AccountController_Accessor.ErrorCodeToString(createStatus);
            
            Assert.IsInstanceOfType(actual, typeof(string));
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for LogOff
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void LogOffTest()
        {
            AccountController target = new AccountController(); // Initialize controller
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize expected to view type
            ActionResult actual;
            actual = target.LogOff();

            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for LogOn
        ///</summary>
        [TestMethod()]
        [UrlToTest("http://localhost:1034/")]
        public void LogOnTest()
        {
            AccountController target = new AccountController(); // Initialize controller
            LogOnModel model = new LogOnModel(); // Initialize a model for log on
            string returnUrl = string.Empty; // Initialize a return url
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize expected to view type
            ActionResult actual;
            actual = target.LogOn(model, returnUrl);

            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

        }

        /// <summary>
        ///A test for LogOn
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void LogOnTestWithoutParams()
        {
            AccountController target = new AccountController(); // Initialize controller
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize expected to view type
            ActionResult actual;
            actual = target.LogOn();

            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for Register
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void RegisterTest()
        {
            AccountController target = new AccountController(); // Initialize controller
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize expected to view type we are expecting
            ActionResult actual;
            actual = target.Register();

            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for Register
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void RegisterTestWithModel()
        {
            AccountController target = new AccountController(); // Initialize controller
            RegisterModel modelTest = new RegisterModel();  //Initialize a Register Model
            modelTest.Email = "test@hotmail.com";
            modelTest.UserName = "TestUser";
            modelTest.Password = "Pa$$word";
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize expected to view type
            ActionResult actual;
            actual = target.Register(modelTest);

            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);

            //Check whether return value is null
            Assert.IsNotNull(actual);
        }
    }
}
